﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.Sql;

namespace QuanLyThuVien.DAL
{
    class daoDocGia
    {
        Connection connect = new Connection();

        public bool SuaDocGia(String MaDocGia, String TenDocGia)
        {
            SqlParameter[] Parameters = new SqlParameter[2];
            Parameters[0] = new SqlParameter("@MaDocGia", SqlDbType.VarChar, 10);
            Parameters[0].Value = MaDocGia;
            Parameters[1] = new SqlParameter("@TenDocGia", SqlDbType.NVarChar, 50);
            Parameters[1].Value = TenDocGia;
            return connect.executeUpdateProcedureQuery("SuaDocGia", Parameters);
        }

        public bool ThemDocGia(String MaDocGia, String TenDocGia)
        {
            SqlParameter[] Parameters = new SqlParameter[2];
            Parameters[0] = new SqlParameter("@MaDocGia", SqlDbType.VarChar, 10);
            Parameters[0].Value = MaDocGia;
            Parameters[1] = new SqlParameter("@TenDocGia", SqlDbType.NVarChar, 50);
            Parameters[1].Value = TenDocGia;
            return connect.executeInsertProcedureQuery("ThemDocGia", Parameters);
        }

        public bool XoaDocGia(String MaDocGia)
        {
            SqlParameter[] Parameters = new SqlParameter[1];
            Parameters[0] = new SqlParameter("@MaDocGia", SqlDbType.VarChar, 10);
            Parameters[0].Value = MaDocGia;
            return connect.executeDeleteProcedureQuery("XoaDocGia", Parameters);
        }

        public DataTable TimDocGia(String MaDocGia, String TenDocGia)
        {
            SqlParameter[] Parameters = new SqlParameter[2];
            Parameters[0] = new SqlParameter("@MaDocGia", SqlDbType.VarChar, 10);
            Parameters[0].Value = MaDocGia;
            Parameters[1] = new SqlParameter("@TenDocGia", SqlDbType.NVarChar, 50);
            Parameters[1].Value = TenDocGia;
            return connect.executeSelectProcedureQuery("TimDocGia", Parameters);
        }
    }
}
